package jk.framework.canary.core.version;

import jk.framework.canary.core.po.VersionInfo;
import jk.framework.canary.core.repository.VersionInfoRepository;

/**
 * @author cuichao
 * 金丝雀发布控制器
 */
public class VersionController {

    private VersionInfoRepository repository;


    public VersionController() {
    }

    public VersionController(VersionInfoRepository repository) {
        this.repository = repository;
    }

    /**
     * 添加一个版本信息
     *
     * @param version
     */
    public void add(VersionInfo version) {
        repository.add(version);
    }

    /**
     * 发布一个版本信息
     *
     * @param version
     */
    public void publish(VersionInfo version) {
        repository.add(version);
    }

    /**
     * 完成一个版本的发布
     *
     * @param version
     */
    public void completion(VersionInfo version) {
        repository.completion(version);
    }

    /**
     * 获取到目标版本号
     *
     * @return
     */
    public VersionInfo targetVersion() {
        return repository.targetVersion(null);
    }

    /**
     * 获取本地当前版本号
     * @return
     */
    public VersionInfo localCurrentVersion(){
        return repository.localCurrentVersion();
    }

}
